<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<link rel="stylesheet"
	href="${ctx}/static/js/lib/ztree/css/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script type="text/javascript"
	src="${ctx}/static/js/lib/ztree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript"
	src="${ctx}/static/js/lib/ztree/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript">
var _rs_image_path = _ctx+"/static/images";
	$(function() {
		
	});
	function changLimitType(){
		var limitType=$("input[name='limitType']:checked").val();
		for(var i=1;i<4;i++){
			$("#beginValue"+i).attr("disabled", "disabled");
			$("#endValue"+i).attr("disabled", "disabled");
		}
		$("#beginValue"+limitType).removeClass("disabled").attr("disabled", null);
		$("#endValue"+limitType).removeClass("disabled").attr("disabled", null);
	}
	
	/**
	 *第一个日期控件选择后，如果第二个日期控件未选择日期，则将当前时间赋给
	 */
	function putDate() {
		if (document.getElementById("endValue1").value == '') {
		    var date = new Date();
			var now = "";
			now = date.getFullYear()+"-"; 
			now = now + (date.getMonth()+1)+"-";//取月的时候取的是当前月-1如果想取当前月+1就可以了
			now = now + date.getDate()+" ";
			now = now + date.getHours()+":";
			now = now + date.getMinutes()+":";
			now = now + date.getSeconds();
			document.getElementById("endValue1").value = now; //将当前时间赋给第二个日控件
		}
	}
	
	/**
	 *文档加载完成后执行
	 */
	var nodeSetting = {
		async : {
			enable : true,
			url : _ctx + "/registry/data_tree.do",
			autoParam : [ "type","id","select"],
			dataFilter : filter
		},
		view : {
			fontCss : getFont,
			nameIsHTML : true,
			selectedMulti : false
		},
		check : {
			enable : true
		},
		data : {
			simpleData : {
				enable : true
			}
		},
		callback : {
			onCheck : zTreeOnCheck,
			onClick : getOwnInfo
		}
	};
	var zNodes = ${treeData};
	 var zTree;
	$(document).ready(function() {
		$.fn.zTree.init($("#treeDemo"), nodeSetting, zNodes);
		zTree = $.fn.zTree.getZTreeObj("treeDemo");
	});
	function zTreeOnCheck(event, treeId, treeNode) {
		zTree.expandNode(treeNode, true);
	}
	function filter(treeId, parentNode, childNodes) {
		if (!childNodes)
			return null;
		for ( var i = 0, l = childNodes.length; i < l; i++) {
			childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
		}
		return childNodes;
	}
	function getFont(treeId, node) {
		var temp = node.font ? node.font : {};
		return temp
	}
	function getOwnInfo(event, treeId, treeNode) {
		var ownId = treeNode.id;
		var type="${type}";
		var select= treeNode.select;
		if(ownId == "" || ownId ==null ){
			return false;	
		}
		if(select == "false" || select ==false ){
			return false;	
		}
	    $.ajax({
			   type: "GET",
			   dataType:"html",
			   cache: false,
			   url: _ctx + "/registry/own_info_get.do",
			   data: {ownId:ownId,type:"${type}"},
			   success: function( content ){
				   $('#own_data').html( content ); 
			   },
			   error:function(){
				   ui.msg('信息加载错误', 0);
			   }
		});
	}
	function setValue(){
		var limitType=$("input[name='limitType']:checked").val();
		$("#beginValue").val($("#beginValue"+limitType).val());
		$("#endValue").val($("#endValue"+limitType).val());
	}
</script>
<style type="text/css">
div.zTreeDemoBackground {
	width: 340px;
	height: 460px;
	text-align: left;
}

ul.ztree {
	margin-top: 10px;
	border: 1px solid #CCC;
	height: 450px;
	overflow-y: auto;
	overflow-x: auto;
	font-size: 13px;
}

.ztree * {
	padding: 0;
	margin: 0;
	font-size: 13px;
	font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif;
}
</style>
<div class="col-sm-4">
	<div class="table-responsive">
		<div id="treeDiv">
			<div class="zTreeDemoBackground">
				<ul id="treeDemo" class="ztree"></ul>
			</div>
		</div>
	</div>
</div>
<div class="col-sm-8">
	<div id="own_data"></div>
</div>
